<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>3D立方体</title>
    <style>
        html
        {
            width: 100%;
            height: 100%;
        }
        body
        {
            width: 100%;
            height: 100%;
            margin: 0;
            display: flex;
            justify-content: center;
            align-items: center;
            perspective: 1000px;
            perspective-origin: 10% 80%;
            background-color: black;
        }
        main
        {
            width: 300px;
            height: 300px;
            /*让子元素保留3d效果*/
            transform-style: preserve-3d;
            animation: mymove 30s linear infinite;
            transition: 5s;
        }
        div
        {
            width: 300px;
            height: 300px;
            position: absolute;
            border: 1px solid white;
            box-sizing: border-box;
            opacity: 0.5;
        }
        .forward
        {
            background-image: url(1.jpg);
            transform: translateZ(150px);
        }
        .backward
        {
            background-image: url(2.jpg);
            transform: translateZ(-150px);
        }
        .left
        {
            background-image: url(3.jpg);
            transform: rotateY(-90deg) translateZ(150px);
        }
        .right
        {
            background-image: url(4.jpg);
            transform: rotateY(90deg) translateZ(150px);
        }
        .top
        {
            background-image: url(5.jpg);
            transform: rotateX(90deg) translateZ(150px);
        }
        .bottom
        {
            background-image: url(6.jpg);
            transform: rotateX(-90deg) translateZ(150px);
        }
        
        @keyframes mymove
        {
            0%{
                transform:rotateX(0deg) rotateY(0deg);
            }
            100%{
                transform:rotateX(720deg) rotateY(720deg);
            }
        }
        main:hover
        {
            transform: rotateY(90deg);
        }
    </style>
</head>
<body>
    <main>
        <div class="forward"></div>
        <div class="backward"></div>
        <div class="left"></div>
        <div class="right"></div>
        <div class="top"></div>
        <div class="bottom"></div>
    </main>
</body>
</html>